﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using InstantMessenger.UserControls;
using InstantMessenger.Interaction;
using InstantMessenger.MessengerServices;

namespace InstantMessenger.Forms
{
    public partial class FrmMain : Form, IControlChangable
    {
        private MessengerServicesClient _currentService = null;

        public FrmMain()
        {
            InitializeComponent();
            _currentService = new MessengerServicesClient();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            //init position form
            InitPositionForm();
            //set login control is default
            ChangeToLoginControl();
        }
        #region Helpers
        /// <summary>
        /// Set position form in screen
        /// </summary>
        private void InitPositionForm()
        {
            int x, y;
            x = Screen.PrimaryScreen.WorkingArea.Width - Width;
            y = 0;
                        
            //set location
            Location = new Point(x, y);
            //set height
            Height = Screen.PrimaryScreen.WorkingArea.Height;
            
        }       

        private void ChangeControl(Control control)
        {
            pnMain.Controls.Clear();
            control.Dock = DockStyle.Fill;
            pnMain.Controls.Add(control);
        }
        #endregion

        #region Implement changable control
        public void ChangeToRegiserControl()
        {
            ChangeControl(new UCRegister(this, _currentService));
        }

        public void ChangeToLoginControl()
        {
            ChangeControl(new UCLogin(this, _currentService));
        }

        public void ChangeToForgotPassword()
        {
            ChangeControl(new UCForgotPassword(this, _currentService));
        }
        #endregion
    }
}
